Skip to content

Conversation

@bmrips
Copy link
Contributor

@bmrips bmrips commented Nov 23, 2025

Description

This PR fixes two things in the programs.less module:

  • Enable an option to be specified multiple times by assigning a list of values to the option. While the machinery works, this is currently limited by the type of the option.
  • The --color/-D and --prompt/-P options need to occur in a certain order (see the comments in the code and the less(1) man page for more information)

Checklist

  • Change is backwards compatible.

  • Code formatted with nix fmt or
    nix-shell -p treefmt nixfmt deadnix keep-sorted --run treefmt.

  • Code tested through nix run .#tests -- test-all or
    nix-shell --pure tests -A run.all.

  • Test cases updated/added. See example.

  • Commit messages are formatted like

    {component}: {description}
    
    {long description}
    

    See CONTRIBUTING for more information and recent commit messages for examples.

  • If this PR adds a new module

    • Added myself as module maintainer. See example.
    • Generate a news entry. See News
    • Basic tests added. See Tests
  • If this PR adds an exciting new feature or contains a breaking change.

    • Generate a news entry. See News

@teto
Copy link
Collaborator

teto commented Nov 24, 2025

if order matters, maybe "options" should be made into a list instead of an attrset. I applaud what you've done but I fear this makes more complex. Let's see what @Pamplemousse thinks

@khaneliman
Copy link
Collaborator

if order matters, maybe "options" should be made into a list instead of an attrset. I applaud what you've done but I fear this makes more complex. Let's see what @Pamplemousse thinks

List or using lib.hm.types.dagOf with the attrs should work instead of manually separating and managing attrsets like that.

@bmrips bmrips force-pushed the less-multi-options branch from 9e9aca9 to 1e294f1 Compare December 7, 2025 08:48
@bmrips bmrips force-pushed the less-multi-options branch from 1e294f1 to afc3090 Compare December 7, 2025 13:49
@bmrips
Copy link
Contributor Author

bmrips commented Dec 7, 2025

Ok, thank you for the input. I went for the list approach. And by coercing the attrs to a list with lib.cli.toGNUCommandLine, we can even stay backwards compatible.

{
programs.less = {
enable = true;
options = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recommend trying to use both a list and attrset with mkBefore/mkAfter.

But otherwise LGTM

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recommend trying to use both a list and attrset with mkBefore/mkAfter.

Wow, I did not know that you could use mkBefore/mkAfter on attrsets because they do not have any notion of order. This implies that there is no need to change anything to solve the order issue.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't, attrset is still lexicographically ordered.

But the list it will be coerced to should use the module order that was applied to the option?

@bmrips bmrips force-pushed the less-multi-options branch from afc3090 to 803a72f Compare December 7, 2025 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants